<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>送花</title>
</head>
<body>
    <script>
        function func(){
            let c=3;//局部变量
        }
        //全局变量
        //变量名    地址的映射  属于运行环境的作用域
        var a=1;//var es5 及之前变量常量声明的关键词
        let b=2;//es6 2015 之后提供的let const
        const name ="张三";
        let age = 20;
        const hometowm = "南昌";
        const sex = '男';
        const obj = {
            name:'zhangsan',
            age:'20',
            hometown:'南昌',
            sex:'男'
        };

        // 函数名大写，类的构造函数
        function Flower(type, num){
            //指针
            //this指向构造函数运行时的结果对象
            console.log(this)
            this.type = type;
            this.num = num;
        }
        //构造哪个对象时就指向哪个
        const rose = new Flower('玫瑰花',1);
        console.log(rose.type,rose.num);
        const ych = new Flower('油菜花',2);
        console.log(ych.type);

        const zk = {
            name:'zk',
            age:'20',
            hometowm:'fc',
            siSingle: true,
            ru:null,
            yz:85,
            work:undefined,
            sendFlower(target) {
                //this指向对象
                //this属于函数
                const flower = new Flower('红玫瑰',99);
                console.log(this);
                // console.log(ruqi);
                //送花代码
                //target 类型是对象，对象上有sendFlower()方法
                target.reviceFlower(this,flower);

            }
        }
        
        // 女主角
        //[]数组{}对象
        const ruqi ={
             name:'ruqi',
             age:'18',
            reviceFlower(sender,flower){
                console.log('收到了'+sender.name+'送的花'
                +flower.num+'朵'+flower.type);
            }
           
        } 
        //xueze是代理人
        const xueze={
            name:'xueze',
            hometown:'fc',
            //接口，代理者
            reciveFlower(sender,flower){
                // console.log('yes'),
                // target.reciveFlower(zk);
                // if(sender.name=='zk'){
                //     console.log('你是哥吗')
                // }
                xueze.reciveFlower(sender,flower)
                if(sender.yz<90){
                    console.log('不收')
                }
                else {
                    console.log('万达走一波');
                    ruqi.reciveFlower(sender,flower);
                }
            }
        }

        zk.sendFlower(xueze);
        //console.log(xx);
        // class Flower {
        //     constructor(){

        //     }
        // }

        // class Flower{
        //     constructor(){

        //     }
        // }
        
        
    </script>
</body>
</html>